{extend name="common/form" /}
{block name="form" /}
<div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
    <div class="widget am-cf">
        <div class="widget-head am-cf">

            <div class="widget-title am-fl">修改文章</div>
            <div class="widget-function am-fr">
                <a href="javascript:;" class="am-icon-cog"></a>
            </div>
        </div>
        <div class="widget-body am-fr">
            <form class="am-form tpl-form-line-form">
                <input type="hidden" name="id" value="{$info.id|default=''}">
                <div class="am-form-group">
                    <label for="user-name" class="am-u-sm-3 am-form-label">
                        文章位置 </label>
                    <div class="am-u-sm-9">
                        <select name="type_id" data-am-selected="{searchBox: 2}">
                            {foreach $type_list as $v}
                            <option value="{$v.id}"  {present name='$info.type_id' } {eq name="$info.type_id"  value="$v.id"}selected{/eq}{else /} {eq name="$Request.param.type_id"  value="$v.id"}selected{/eq}{/present}>{$v.name}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="am-form-group">
                    <label for="user-name" class="am-u-sm-3 am-form-label">
                        公告标题 </label>
                    <div class="am-u-sm-9">
                        <input type="text" name="title" value="{$info.title|default=''}" required="required"
                               class="tpl-form-input" placeholder="请填写公告标题">
                    </div>
                </div>
                <div class="am-form-group">
                    <label for="user-name" class="am-u-sm-3 am-form-label">
                        文章内容 </label>
                    <div class="am-u-sm-9">
                        <textarea id="content" name="content"/>{$info.content|default=''}</textarea>
                    </div>
                </div>
                <div class="am-form-group">
                    <label for="user-name" class="am-u-sm-3 am-form-label">
                        是否置顶 </label>
                    <div class="am-u-sm-9">
                        <div class="tpl-switch">
                            <input type="checkbox" name="is_top"
                                   class="ios-switch bigswitch tpl-switch-btn am-margin-top-xs" {present
                                   name='$info.is_top' }{eq name='$info.is_top' value="1" }checked{/eq} {/present}>
                            <div class="tpl-switch-btn-view">
                                <div></div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="am-form-group">
                    <label for="user-name" class="am-u-sm-3 am-form-label">
                        是否显示 </label>
                    <div class="am-u-sm-9">
                        <div class="tpl-switch">
                            <input type="checkbox" name="is_show"
                                   class="ios-switch bigswitch tpl-switch-btn am-margin-top-xs" {present
                                   name='$info.is_show' }{eq name='$info.is_show' value="1" }checked {/eq} {else /} checked{/present}>
                            <div class="tpl-switch-btn-view">
                                <div></div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="am-form-group">
                    <div class="am-u-sm-9 am-u-sm-push-3">
                        <button type="button" onclick="$('#content').val(CKEDITOR.instances['content'].getData());add('{:url("")}','form')"
                                class="am-btn am-btn-primary tpl-btn-bg-color-success">
                            提交
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
{/block}
{block name='script'}
<!--<script src="/demock/js/plupload.full.min.js"></script>-->
<script src="/static/js/ckeditor/ckeditor.js"></script>
<script type="text/javascript">



    CKEDITOR.editorConfig = function( config ) {
        config.filebrowserUploadUrl = "{:url('up/upImage1')}";
    };
    CKEDITOR.replace('content',{height:"700px"});

    //修改
    CKEDITOR.instances['content'].on('fileUploadResponse', function (evt) {
//        evt.stop()
        console.log(343)
        var data = evt.data
        var xhr = data.fileLoader.xhr
        var status = xhr.status
        if (status === 200) {
            var res = JSON.parse(xhr.response)
            data.url = res.data;
        } else {
            evt.cancel()
        }
    });

</script>
{/block}
{extend}
